package com.zhu.salesmanagement.models;

import android.util.Log;

import com.zhu.salesmanagement.views.CRCInfoView;
import com.zhu.salesmanagement.views.ProductInfoListView;

/**
 * CRC数据项
 */
public class CRCinfoItem {
    public String sCustomerID;
    public String sProductCategoryID;
    public String mInfo = "";
    public String sImportantMSG;
    public String sCompetitionMSG;

    public int mType;

    /**
     * 设置产品信息
     * @param pid 大类ID
     * @param layer 层
     * @param area 面
     * @param decStockQty 库存
     * @param sid 特陈
     */
    public void setInfo(String pid, String layer, String area, String decStockQty, String sid){
        layer = getValue(layer);
        area = getValue(area);
        decStockQty = getStockValue(decStockQty);
        sid = getValue(sid);

        String row = pid + CRCInfoView.SPLIT_RANK + layer + CRCInfoView.SPLIT_RANK + area + 
        CRCInfoView.SPLIT_RANK + decStockQty + CRCInfoView.SPLIT_RANK + sid;
        mInfo += (row + CRCInfoView.SPLIT_ROW);
    }

    private String getValue(String text){
        if(text == null || text.trim().length() == 0 ||text.equals("-1")){
            text = ProductInfoListView.DEFAULT;
        }
        return text;
    }

    /**
     * 获取库存值
     * @param text 库存
     */
    private String getStockValue(String text){
        if(text == null || text.trim().length() == 0 ||text.equals("-1")){
            text = ProductInfoListView.DEFAULT;
        }else{
        	double v = Double.parseDouble(text);
            if(v == -1){
                text = ProductInfoListView.DEFAULT;
            }
        }
        return text;
    }
}
